<?php

use Biz\model\brand\Brand;
use Biz\module\Classes\wiki\Infos;
use Biz\service\CategoryInfo as sCategoryInfo;
use Doraemon\cache\Search\SpecialWord;
use Doraemon\cache\Wiki\SearchBanner;
use Doraemon\cache\Wiki\SearchBrandScore;
use Doraemon\cache\Wiki\SearchContent;
use Doraemon\model\Elasticsearch\EsWikiListModel;
use Biz\pockets\constInterface\SourceRightsInterface;
use Biz\service\esSearch\Wiki as esWiki;
use Doraemon\service\es\EsWikiBasic;
use Doraemon\service\search\BrandCollectSearch;

class TestWikiAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        // $uid = $this->uid;
        // $wikiIds = $this->getRequest()->getQuery('wiki_ids', '');
        // $wikiIds=explode(',',$wikiIds);
        // $fieldsGroup = $this->getRequest()->getQuery('fieldsGroup', 'list');
        // if (empty($wikiIds)) {
        //     throw new \Exception("参数错误！");
        // }
        // $data=Infos::infos($wikiIds, $fieldsGroup, $uid);

        // $data = EsWikiListModel::getGroupBrandGoods([1024,2156],[1,4]);

        // $data = EsWikiListModel::searchBrandBanner('北欧真皮床简约现代1.5');
        // $data = EsWikiListModel::getWikiListForActivity(1,20,[1024,2156]);
        // $data = EsWikiListModel::brandPlanRule1('哈哈');
//        $data = EsWikiListModel::appCategoryList();
        // $data = EsWikiListModel::brandPlanRule2();

        // $params = array(
        //     "goods_tag" => '轻奢',
        //     "fl" => "id,brand_uid,brand_id,cover_img",
        //     "brand_type" => implode(",", array(
        //         Brand::BRAND_TYPE_BEST,
        //         Brand::BRAND_TYPE_SUPER,
        //     )),
        //     "filter_brand_ids" => implode(",", \Doraemon\service\WikiBasic\Schedule::FILTER_BRAND_IDS),
        //     "status" => implode(",", array(1)) // 上线状态
        // );
        // var_dump($params);die;

        // $data = EsWikiBasic::BrandPlanRule2($params);

//        $categoryId = sCategoryInfo::getAdmCategoryIdByParentId(531);
//        $categoryId = array_filter($categoryId);
//        $data = esWiki::getList(['category_id' => $categoryId], EsWikiListModel::SCENES_APP_WIKI_CATEGORY_CARD);
//        $data = EsWikiListModel::getList(['category_id' => $categoryId], EsWikiListModel::SCENES_APP_WIKI_CATEGORY_CARD);


//        wiki_ol :app_category_list ->pro环境测试数据
//        $where = ['category_id'=>[240,567,116,117]];
//        $data = esWiki::getList($where, esWiki::SCENES_APP_CATEGORY_LIST, 1, 1);
//        $data = EsWikiListModel::getList($where, EsWikiListModel::SCENES_APP_CATEGORY_LIST, 1, 1);


        // $where = [
        //     'shop_uid' => 123
        // ];
        // // $data = esWiki::getList($where, esWiki::SCENES_APP_SHOP_WIKI_LIST, 1, 1);
        // $data = EsWikiListModel::getList($where, esWiki::SCENES_APP_SHOP_WIKI_LIST, 1, 1);


        // $data = esWiki::getList(['category_id' => [1,2,3],'tag'=>'轻奢'], esWiki::SCENES_APP_PRESET_CONDITION, 0, 1, 20, ['brand_id']);
//        $data = EsWikiListModel::getList(['category_id' => [1,2,3],'tag'=>'轻奢'], esWiki::SCENES_APP_PRESET_CONDITION, 0, 1, 20, ['brand_id']);


//        $keyword = '戴尔';
//        $data = BrandCollectSearch::Search($keyword, 1, 2);
//        $data = \Doraemon\model\Elasticsearch\EsBrandCollectModel::searchBrandList($keyword, 1, 2);


//        BrandPlanRule1
//        $brandIds = [270,271,276];
//        $group_size = 2;
//        $params = array(
//            "brand_ids" => implode(",",$brandIds ),
//            "fl" => "cover_img,brand_id",
//            "status" => implode(",", array(1)),
//            "filter_cover_img" => 1,
//            "group_size" => $group_size
//        );

//      $data = EsWikiBasic::BrandPlanRule1($params);
//        $data = EsWikiListModel::brandPlanRule1('',$brandIds,$group_size);



//        BrandPlanRule2
//        $secondCategorys = SpecialWord::getAllSecondCategory();
//        $data = [];
//        $cateIds = [530,531,534];
//        $params = array(
//            "category_ids" => implode(",", $cateIds),
//            "filter_brand_ids" => implode(",", \Doraemon\service\WikiBasic\Schedule::FILTER_BRAND_IDS),
//            "fl" => "id,brand_uid,brand_id,cover_img",
//            "select_brand_rights" => implode(",", array(
//                SourceRightsInterface::RECOM_SEARCH
//            )),
//            "status" => implode(",", array(1)) // 上线状态
//        );
//        $data = EsWikiBasic::BrandPlanRule2($params);
//        $data = EsWikiListModel::brandPlanRule2('',$cateIds,[SourceRightsInterface::RECOM_SEARCH]);


        // app_preset_condition pro
//        $cateIds = [530,531,534];
//        $data = esWiki::getList(['category_id' => $cateIds], esWiki::SCENES_APP_PRESET_CONDITION, 0, 1, 20, ['brand_id']);
//        $data = EsWikiListModel::getList(['category_id' => $cateIds], EsWikiListModel::SCENES_APP_PRESET_CONDITION, 0, 1, 20, ['brand_id']);
//        if (!$results['is_over']) {
//            $results = esWiki::getList(['category_id' => $cateIds], esWiki::SCENES_APP_PRESET_CONDITION, 0, 1, $results['total'] > 10000 ? 10000 : $results['total'], ['brand_id']);
//            $results = EsWikiListModel::getList(['category_id' => $cateIds], EsWikiListModel::SCENES_APP_PRESET_CONDITION, 0, 1, $results['total'] > 10000 ? 10000 : $results['total'], ['brand_id']);
//        }



        $data = \Doraemon\model\Elasticsearch\EsBrandCollectModel::searchBrandList("日", 1, 500);

        $this->setSuccess($data, self::API_CODE_SUCCES);
    }
}